<?php
namespace app\admin\controller;
use think\Controller;
use think\Db;//导入数据库类(Db类)
session_start();


class Login extends Controller
{
	public function login()
	{
	$tel = $_POST['tel'];
    	$pwd = $_POST['pwd'];
    if($log = Db::table('boke_user')->where('tel',$tel)->select()){
    		if(md5($pwd)==$log[0]['pwd']){
    			$_SESSION['admin']['tel'] = $log[0]['tel'];
    			$_SESSION['admin']['nickname'] = $log[0]['nickname'];
    			$this->success('登录成功','Dashboard/dashboard');
    		}else{
    			$this->error('密码错误','index/index');
    		}

    }else{
    	$this->error('无此用户','index/index');
    }

  }

  	  //退出登录
    public function goout()
    {
    	unset($_SESSION['admin']);
    	$this->success('退出成功',url('Admin/index/index'),'',1);
    }
}

